package com.dormms.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dormms.bean.StaffInfo;
import com.dormms.service.StaffInfoService;
import com.dormms.tool.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@Controller
public class StaffController {
	@Autowired
	private StaffInfoService staffInfoService;
	
	@RequestMapping("super/queryStaffInfoByPage")
	@ResponseBody
	public PageInfo<StaffInfo> queryStaffInfoByPageBySuper(Page page, StaffInfo staffInfo){
		PageHelper.startPage(page.getCurrPage(), page.getPageSize());
		List<StaffInfo> staffInfos = staffInfoService.queryStaffInfoByStaffInfo(staffInfo);
		PageInfo<StaffInfo> pageInfo = new PageInfo<StaffInfo>(staffInfos);
		return pageInfo;
	}
	
	@RequestMapping("super/insertStaffInfo")
	@ResponseBody
	public Integer insertStaffInfo(StaffInfo staffInfo) {
		return staffInfoService.insertStaffInfo(staffInfo);
	}
	
	@RequestMapping("super/updateStaffInfoBySuper")
	@ResponseBody
	public Integer updateStaffInfoBySuper(StaffInfo staffInfo) {
		return staffInfoService.updateStaffInfoBySuper(staffInfo);
	}
	
	@RequestMapping("super/queryStaffInfoByStaffId")
	@ResponseBody
	public StaffInfo queryStaffInfoByStaffId(String staffId) {
		StaffInfo staffInfo = staffInfoService.queryStaffInfoByStaffId(staffId);
		if("".equals(staffInfo.getStaffId())) {
			return null;
		}
		return staffInfo;
	}
	
	@RequestMapping("super/deleteStaffInfo")
	@ResponseBody
	public Integer deleteStaffInfo(String staffId) {
		return staffInfoService.deleteStaffInfo(staffId);
	}
}
